package com.example.test;

import com.example.tcls.DelegateMoo;
import com.example.tcls.Moo;

import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.matcher.ElementMatchers;

public class TDelegateMoo {

	public static void main(String[] args) throws Exception{
		Moo moo = new ByteBuddy()
	            .subclass(Moo.class)
	            .method(ElementMatchers.named("Moo").or(ElementMatchers.named("Moo1")))
	            .intercept(MethodDelegation.to(DelegateMoo.class))
	            .make()
	            .load(ClassLoader.getSystemClassLoader())
	            .getLoaded()
	            .newInstance();

	    System.out.println("moo:" +  moo.Moo("tinysakura", 21));
	    System.out.println("moo1:" + moo.Moo1("tinysakura"));
	}

}
